home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Utilities / Stuart / slog / SLogListener.m < prev   
Text File  |  1992-07-03  |  3KB  |  148 lines

  1. #import <appkit/appkit.h>
  2. #import "SLogListener.h"
  3. #import <mach.h>
  4. #import <sys/message.h>
  5. #import <servers/netname.h>
  6. extern port_t name_server_port;
  7. extern id NXResponsibleDelegate();
  8. @implementation  SLogListener :Listener
  9. {}
  10. static NXRemoteMethod *remoteMethods = NULL;
  11. #define REMOTEMETHODS 5
  12. + (void)initialize 
  13. /* */
  14. {
  15.     if (!remoteMethods) {
  16.     remoteMethods =
  17.     (NXRemoteMethod *) malloc((REMOTEMETHODS+1)*sizeof(NXRemoteMethod));
  18.     remoteMethods[0].key = 
  19.     @selector(login:ownerships:utmp:wtmp:lastlog:);
  20.     remoteMethods[0].types = "ciiii";
  21.     remoteMethods[1].key = 
  22.     @selector(login:ownerships:utmp:);
  23.     remoteMethods[1].types = "cii";
  24.     remoteMethods[2].key = 
  25.     @selector(logout:ownerships:utmp:wtmp:lastlog:);
  26.     remoteMethods[2].types = "ciiii";
  27.     remoteMethods[3].key = 
  28.     @selector(logout:ownerships:utmp:);
  29.     remoteMethods[3].types = "cii";
  30.     remoteMethods[4].key = 
  31.     @selector(exit);
  32.     remoteMethods[4].types = "";
  33.     remoteMethods[REMOTEMETHODS].key = NULL;
  34.     }
  35. }
  36. -(int)login : (char *) pty
  37.     ownerships : (int) oFlag
  38.     utmp : (int) uFlag
  39.     wtmp : (int) wFlag
  40.     lastlog : (int) lFlag
  41. /* */
  42. {
  43.     id _NXd;
  44.     if (_NXd = NXResponsibleDelegate(self,
  45.     @selector(login:ownerships:utmp:wtmp:lastlog:)))
  46.     return [_NXd login : pty
  47.         ownerships : oFlag
  48.         utmp : uFlag
  49.         wtmp : wFlag
  50.         lastlog : lFlag];
  51.     return -1;
  52. }
  53.  
  54. -(int)login : (char *) pty
  55.     ownerships : (int) oFlag
  56.     utmp : (int) uFlag
  57. /* */
  58. {
  59.     id _NXd;
  60.     if (_NXd = NXResponsibleDelegate(self,
  61.     @selector(login:ownerships:utmp:)))
  62.     return [_NXd login : pty
  63.         ownerships : oFlag
  64.         utmp : uFlag];
  65.     return -1;
  66. }
  67.  
  68. -(int)logout : (char *) pty
  69.     ownerships : (int) oFlag
  70.     utmp : (int) uFlag
  71.     wtmp : (int) wFlag
  72.     lastlog : (int) lFlag
  73. /* */
  74. {
  75.     id _NXd;
  76.     if (_NXd = NXResponsibleDelegate(self,
  77.     @selector(logout:ownerships:utmp:wtmp:lastlog:)))
  78.     return [_NXd logout : pty
  79.         ownerships : oFlag
  80.         utmp : uFlag
  81.         wtmp : wFlag
  82.         lastlog : lFlag];
  83.     return -1;
  84. }
  85.  
  86. -(int)logout : (char *) pty
  87.     ownerships : (int) oFlag
  88.     utmp : (int) uFlag
  89. /* */
  90. {
  91.     id _NXd;
  92.     if (_NXd = NXResponsibleDelegate(self,
  93.     @selector(logout:ownerships:utmp:)))
  94.     return [_NXd logout : pty
  95.         ownerships : oFlag
  96.         utmp : uFlag];
  97.     return -1;
  98. }
  99.  
  100. -(int)exit
  101. /* */
  102. {
  103.     id _NXd;
  104.     if (_NXd = NXResponsibleDelegate(self,
  105.     @selector(exit)))
  106.     return [_NXd exit];
  107.     return -1;
  108. }
  109.  
  110. - (int) performRemoteMethod : (NXRemoteMethod *) method
  111.                   paramList : (NXParamValue *) paramList {
  112. /* */
  113.     switch (method - remoteMethods) {
  114.     case 0:
  115.     return [self login : paramList[0].bval.p
  116.         ownerships : paramList[1].ival
  117.         utmp : paramList[2].ival
  118.         wtmp : paramList[3].ival
  119.         lastlog : paramList[4].ival];
  120.     case 1:
  121.     return [self login : paramList[0].bval.p
  122.         ownerships : paramList[1].ival
  123.         utmp : paramList[2].ival];
  124.     case 2:
  125.     return [self logout : paramList[0].bval.p
  126.         ownerships : paramList[1].ival
  127.         utmp : paramList[2].ival
  128.         wtmp : paramList[3].ival
  129.         lastlog : paramList[4].ival];
  130.     case 3:
  131.     return [self logout : paramList[0].bval.p
  132.         ownerships : paramList[1].ival
  133.         utmp : paramList[2].ival];
  134.     case 4:
  135.     return [self exit];
  136.     default:
  137.     return [super performRemoteMethod : method paramList : paramList];
  138.     }
  139. }
  140. - (NXRemoteMethod *) remoteMethodFor: (SEL) aSel {
  141. /* */
  142.     NXRemoteMethod *rm;
  143.     if (rm = NXRemoteMethodFromSel(aSel,remoteMethods))
  144.         return rm;
  145.     return [super remoteMethodFor : aSel];
  146. }
  147. @end
  148.